package com.aiju.listener;

import android.view.View;

import com.aiju.utils.L;


/**
 * @author: 佐为
 * @date: 2017-02-08 09:39
 * @version: V1.0
 * @Description: 过滤某个时间段重复点击的Click事件监听
 */
public abstract class OnDoubleClickListener implements View.OnClickListener {

    private static long lastClickTime;
    private final static int SPACE_TIME = 500;

    @Override
    public void onClick(View v) {
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastClickTime > SPACE_TIME) {
            onDoubleClick(v);
        } else {
            onDoubleError();
        }
        lastClickTime = currentTime;
    }

    public abstract void onDoubleClick(View view);

    protected void onDoubleError() {
        //T.ToastNetError();
        L.d("重复点击");
    }

}
